package com.github.live.util;

import com.github.livebase.bean.Channel;
import com.github.livebase.bean.ChannelGroup;
import com.github.livebase.util.template.CompositeMap;
import com.github.livebase.util.template.Template;

import java.util.List;
import java.util.Map;

/**
 * @ClassName SourceWrapper
 * @description: Channel的包装类, 仅附加信息允许更改
 * @author: biao532
 * @create: 2023-12-28 15:19
 * @Version 1.0
 **/
public class ChannelWrapper extends Channel {
    public ChannelWrapper(Map<String, String> all, ChannelGroup group, Channel channel) {
        super();
        CompositeMap<String, String> map = new CompositeMap<>();
        map.addMap(all, group.getOpt(), channel.getOpt());
        super.setId(channel.getId());
        super.setName(channel.getName());
        super.setLogo(channel.getLogo());
        super.setNumber(channel.getNumber());
        super.setSources(channel.getSources());
        super.setOpt(map);
    }

    @Override
    public void setName(String name) {

    }

    @Override
    public void setSources(List<Source> sources) {

    }

    @Override
    public void setNumber(int number) {

    }

    @Override
    public String getLogo() {
        String logo = super.getLogo();
        if (logo == null) {
            return logo;
        }
        return Template.template.parseExpression(logo)
                .eval(super.getOpt()).toString();
    }

    @Override
    public void setLogo(String logo) {
    }

    @Override
    public void setId(String id) {
    }
}
